home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_12_10
/
saks
/
genq5.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-08
|
768b
|
44 lines
Listing 2 - non-inline member function definitions for a generic queue
using void * and an nested iterator class
//
// genq5.cpp - generic queue of void *
// with an iterator class
//
#include "genq5.h"
void *genq::iterator::next()
{
void *pv = 0;
if (pc != 0)
{
pv = pc->element;
pc = pc->next;
}
return pv;
}
void genq::append(void *e)
{
cell *p = new cell(e, 0);
if (first == 0)
first = p;
else
last->next = p;
last = p;
}
int genq::remove(void *&e)
{
if (first == 0)
return 0;
cell *p = first;
if ((first = first->next) == 0)
last = 0;
e = p->element;
delete p;
return 1;
}